package com.koron.order.repair.controller;

import com.koron.bean.base.Response;
import com.koron.order.common.bean.po.OrderSignBean;
import com.koron.order.common.controller.OrderExecuteController;
import com.koron.order.repair.bean.entity.RepairItemParamsPo;
import com.koron.order.repair.bean.entity.RepairItemPo;
import com.koron.order.repair.bean.entity.RepairPo;
import com.koron.order.repair.bean.entity.RepairReadyPo;
import com.koron.order.repair.bean.vo.OperateFormVo;
import com.koron.order.repair.bean.vo.RepairExecuteVo;
import com.koron.order.repair.bean.vo.RepairItemVo;
import com.koron.order.repair.service.RepairExecuteService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.koron.ebs.mybatis.ADOConnection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ClassName RepairExcuteController
 * @description
 * @Author zhouj
 * @Date 2021/9/16 8:51
 */
@Api(tags = "计划检修工单-执行中信息")
@RestController
@RequestMapping("/repair/execute/")
public class RepairExecuteController extends OrderExecuteController {

    @Autowired
    private RepairExecuteService repairExecuteService;

    @ApiOperation(value = "新增或更新")
    @PostMapping("insertOrUpdate")
    public Response<Integer> insertOrUpdate(@RequestBody RepairExecuteVo repairExecuteVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "insertOrUpdate", Integer.class, repairExecuteVo));
    }

    @ApiOperation(value = "根据id删除 ")
    @DeleteMapping("deleteById")
    public Response<Integer> deleteById(String id) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "deleteById", Integer.class, id));
    }

    @ApiOperation(value = "根据工单Id查询作业表单信息 ")
    @GetMapping("queryByOrderId")
    public Response<OperateFormVo> queryById(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "queryByOrderId", OperateFormVo.class, orderId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-作业准备信息 ")
    @GetMapping("queryReadyByOrderId")
    public Response<List> queryReadyByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "queryReadyByOrderId", List.class, orderId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-作业指导书信息 ")
    @GetMapping("queryInstructionByOrderId")
    public Response<List> queryInstructionByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "queryInstructionByOrderId", List.class, orderId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-设备以及下属项目列表信息 ")
    @GetMapping("queryEquipmentVoByOrderId")
    public Response<List> queryEquipmentVoByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "queryEquipmentVoByOrderId", List.class, orderId));
    }

    @ApiOperation(value = "根据工单Id查询作业表单-设备信息列表信息 ")
    @GetMapping("queryEquipmentBeanListByOrderId")
    public Response<List> queryEquipmentBeanListByOrderId(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "queryEquipmentBeanListByOrderId", List.class, orderId));
    }

    @ApiOperation(value = "根据工单Id,设备id查询作业表单-设备下项目信息列表信息 ")
    @GetMapping("queryRepairItemByEqId")
    public Response<List> queryRepairItemByEqId(String orderId, String repairEquipmentId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "queryRepairItemByEqId", List.class, orderId, repairEquipmentId));
    }

    @ApiOperation(value = "新增或更新作业表单信息")
    @PutMapping("insertOrUpdateOperateForm")
    public Response<String> insertOrUpdateOperateForm(@RequestBody OperateFormVo operateFormVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "insertOrUpdateOperateForm", String.class, operateFormVo));
    }

    @ApiOperation(value = "更新作业表单-作业准备信息")
    @PutMapping("updateRepairReady")
    public Response<Integer> updateRepairReady(@RequestBody RepairReadyPo repairReadyPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "updateRepairReady", Integer.class, repairReadyPo));
    }

    @ApiOperation(value = "更新作业表单-作业过程信息")
    @PutMapping("updateRepairItemVo")
    public Response<Integer> updateRepairItemVo(@RequestBody RepairItemVo repairItemVo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "updateRepairItemVo", Integer.class, repairItemVo));
    }

    @ApiOperation(value = "更新作业表单-作业过程-项目信息")
    @PutMapping("updateRepairItem")
    public Response<Integer> updateRepairItem(@RequestBody RepairItemPo repairItemPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "updateRepairItem", Integer.class, repairItemPo));
    }

    @ApiOperation(value = "更新作业表单-作业过程-参数项值信息")
    @PutMapping("updateRepairItemParams")
    public Response<Integer> updateRepairItemParams(@RequestBody RepairItemParamsPo itemParamsBean) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "updateRepairItemParams", Integer.class, itemParamsBean));
    }

    @ApiOperation(value = "更新作业表单-作业过程-签名信息")
    @PutMapping("insertOrderSignInfo")
    public Response<Integer> insertOrderSignInfo(@RequestBody OrderSignBean orderSignBean) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "insertOrderSignInfo", Integer.class, orderSignBean));
    }

    @ApiOperation(value = "更新作业表单-作业表单-主表信息")
    @PutMapping("updateRepairInfo")
    public Response<Integer> updateRepairInfo(@RequestBody RepairPo repairPo) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "updateRepairInfo", Integer.class, repairPo));
    }

    @ApiOperation(value = "作业标准生成项目及参数项列表")
    @PutMapping("generateStand")
    public Response<Boolean> generateStand(String orderId) {
        return Response.ok(ADOConnection.runTask(getCurrDs(), repairExecuteService, "generateStand", Boolean.class, orderId));
    }

}
